package org.bigdata.framework.core.protocol;

import java.util.HashMap;
import java.util.List;

import org.bigdata.framework.core.model.CommunityUserVisitor;
import org.bigdata.framework.core.model.LiveRoom;
import org.bigdata.framework.core.model.LiveStream;
import org.bigdata.framework.core.service.ILiveRoomService;
import org.bigdata.framework.core.service.ILiveStreamService;
import org.bigdata.framework.core.utils.MybatisPlusTools;
import org.springframework.beans.factory.annotation.Autowired;

import com.baomidou.mybatisplus.plugins.Page;

public class LiveService implements ILiveService {
    
	 @Autowired
	 private ILiveStreamService liveStreamService;
	 @Autowired
	 private ILiveRoomService liveRoomService;
	 //流媒体管理
	 @Override
	    public LiveStream saveLiveStream(
	    		LiveStream liveStream) {
	        boolean r = liveStreamService.insert(liveStream);
	        if (r) {
	            return liveStream;
	        }
	        return null;
	    }
	    @Override
	    public LiveStream editLiveStream(
	    		LiveStream liveStream) {
	        boolean r = liveStreamService.updateAllColumnById(liveStream);
	        if (r) {
	            return liveStream;
	        }
	        return null;
	    }
	    @Override
	    public void deleteLiveStream(LiveStream liveStream) {
	        boolean r = liveStreamService.deleteById(liveStream.getId());
	        if (r) {
	            System.out.println("communityUserVisitor 删除成功>>>" + liveStream.getId());
	        }
	    }
	    @Override
	    public LiveStream findLiveStream(Integer id) {
	        return liveStreamService.selectById(id);
	    }
	    @Override
	    public List<LiveStream> getLiveStream() {
	        return liveStreamService.selectList(null);
	    }
	    @Override
	    public List<LiveStream> getLiveStream(HashMap<String, Object> queryParams,
	            int pageNumber, int pageSize) {
	        return liveStreamService.selectPage(
	                new Page<LiveStream>(pageNumber, pageSize),
	                new MybatisPlusTools<LiveStream>().getEwByList(queryParams))
	                .getRecords();
	    }
	    @Override
	    public Integer getLiveStreamCount(HashMap<String, Object> queryParams) {
	        return liveStreamService.selectCount(new MybatisPlusTools<LiveStream>()
	                .getEwByCount(queryParams));
	    }
	 //直播间管理
	    @Override
	    public LiveRoom saveLiveRoom(
	    		LiveRoom liveRoom) {
	        boolean r = liveRoomService.insert(liveRoom);
	        if (r) {
	            return liveRoom;
	        }
	        return null;
	    }
	    @Override
	    public LiveRoom editLiveRoom(
	    		LiveRoom liveRoom) {
	        boolean r = liveRoomService.updateAllColumnById(liveRoom);
	        if (r) {
	            return liveRoom;
	        }
	        return null;
	    }
	    @Override
	    public void deleteLiveRoom(LiveRoom liveRoom) {
	        boolean r = liveRoomService.deleteById(liveRoom.getId());
	        if (r) {
	            System.out.println("communityUserVisitor 删除成功>>>" + liveRoom.getId());
	        }
	    }
	    @Override
	    public LiveRoom findLiveRoom(Integer id) {
	        return liveRoomService.selectById(id);
	    }
	    @Override
	    public List<LiveRoom> getLiveRoom() {
	        return liveRoomService.selectList(null);
	    }
	    @Override
	    public List<LiveRoom> getLiveRoom(HashMap<String, Object> queryParams,
	            int pageNumber, int pageSize) {
	        return liveRoomService.selectPage(
	                new Page<LiveRoom>(pageNumber, pageSize),
	                new MybatisPlusTools<LiveRoom>().getEwByList(queryParams))
	                .getRecords();
	    }
	    @Override
	    public Integer getLiveRoomCount(HashMap<String, Object> queryParams) {
	        return liveRoomService.selectCount(new MybatisPlusTools<LiveRoom>()
	                .getEwByCount(queryParams));
	    }
	 
}
